package org.lds.logger.config.appender.rolling.compress;

import org.apache.commons.lang3.StringUtils;

import java.util.HashMap;
import java.util.Map;

public enum CompressType {
    GZIP(),
    ZIP(),
    NONE(),
    ;

    CompressType() {

    }

    private static final Map<String, CompressType> COMPRESS_TYPE_MAP;
    static {
        COMPRESS_TYPE_MAP = new HashMap<>();
        COMPRESS_TYPE_MAP.put(GZIP.name().toLowerCase(), GZIP);
        COMPRESS_TYPE_MAP.put(ZIP.name().toLowerCase(), GZIP);
        COMPRESS_TYPE_MAP.put(NONE.name().toLowerCase(), GZIP);
    }

    public static CompressType getCompressType(String compressTypeStr) {
        if (StringUtils.isEmpty(compressTypeStr)) return NONE;
        CompressType compressType = COMPRESS_TYPE_MAP.get(compressTypeStr.toLowerCase());
        if (compressType == null) return NONE;
        return compressType;
    }
}
